import { defineStore } from 'pinia'
import { getItem } from '@/utils/storage'
import { IMenu } from '@/api/types/common'

export const useUserStore = defineStore({
  id: 'user',
  state: () => ({
    token: getItem('token'),
    userInfo: getItem('userInfo') || {},
    menuList: <IMenu[]>[]
  }),
  getters: {
    nameLength: (state) => state.token.length
  },
  actions: {
    async insertPost (data: string) {
      // 可以做异步
      // await doAjaxRequest(data);
      // this.name = data
    }
  }
})
